package P1358;/*
 *   exercise
 *   P1358
 *
 *   description:
 *   @data 2025/5/14     下午3:22
 *   @author 凉风
 */

import java.util.Scanner;

public class Main {
    static final int MOD = 10007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
        }

        // 预处理组合数表：C[i][j] 表示从i中选j个
        int maxA = 0;
        for (int ai : a) {
            maxA = Math.max(maxA, ai);
        }

        // 创建组合数表 C[i][j]
        int[][] C = new int[n + 1][maxA + 1];
        for (int i = 0; i <= n; i++) {
            C[i][0] = 1;
            for (int j = 1; j <= Math.min(i, maxA); j++) {
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
            }
        }

        // 开始计算结果
        int res = 1;
        for (int ai : a) {
            res = (res * C[n][ai]) % MOD;
            n -= ai;
        }

        System.out.println(res);
    }
}